package com.hbusa.cotroller.read;

import com.hbusa.dto.TbChapter;
import com.hbusa.service.ChapterService;
import com.hbusa.service.impl.*;
import com.hbusa.service.service.impl.ChapterServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/doRead")
public class readservelt extends HttpServlet {


    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        ChapterService chapterService = new ChapterServiceImpl();
        List<TbChapter> novelContent = chapterService.findAllChapter();
//        for (TbChapter tbChapter : novelContent) {
//            System.out.println(tbChapter.getChapterNum() + "  " + tbChapter.getChapterName());
//        }
//        System.out.println(novelContent);
        TbChapter chapter = chapterService.findChapterById(6);
        //System.out.println(chapter);

        HttpSession session = req.getSession();
        session.setAttribute("chapter",chapter);
        resp.sendRedirect("/read.jsp");



    }
}
